<html>
<head>
    <title>webSocket demo</title>
</head>

<body>

<script type="text/javascript">
    var ws = new WebSocket("ws://127.0.0.1:8888");
    ws.onopen = function () {
        console.log('握手成功');
        ws.send("hello webSocket");
        ws.send("你好");
    }

    ws.onmessage = function (e) {
        console.log("message:" + e.data);
    }

    ws.onerror = function () {
        console.log('error');
    }

</script>

</body>

</html>